using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MSRI.HelperClasses;
using Instedd.Labs.Geo.Library.Kml;
using Mvp.Xml.Common.Xsl;
using System.Xml;
using System.IO;
using System.Xml.Xsl;
using Instedd.Labs.Geo.Library.Rss;

namespace Instedd.Labs.Geo.Library.Tests.Managers
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class GeoRssManagerFixture
    {
        public GeoRssManagerFixture()
        {
        }

        [TestMethod]
        public void ValidKmlFileWritesTheGeoRssUsingTheXslFile()
        {
            GeoRssManager manager = new GeoRssManager("KmlToGeoRss.xslt");

            string geoRssFileName = "test-generated-feed.rss";
            manager.WriteGeoRss("map.kml", geoRssFileName);

            Assert.IsTrue(File.Exists(geoRssFileName));
            Console.Out.WriteLine(File.ReadAllText(geoRssFileName));
        }

        [ExpectedException(typeof(FileNotFoundException))]
        [TestMethod]
        public void XslFileNotFoundThrows()
        {
            GeoRssManager manager = new GeoRssManager("NotFound.xslt");
        }

        [ExpectedException(typeof(FileNotFoundException))]
        [TestMethod]
        public void KmlFileNotFoundThrows()
        {
            GeoRssManager manager = new GeoRssManager("KmlToGeoRss.xslt");

            string geoRssFileName = System.IO.Path.GetTempFileName();
            manager.WriteGeoRss("NotFound.kml", geoRssFileName);
        }
    }
}